package org.lex.tinyscript.command;

import java.io.File;

import org.lex.tinyscript.TinyScriptException;
import org.lex.tinyscript.utils.FileOperationUtils;
import org.lex.tinyscript.utils.Loggers;

/**
 * Delete a file. Directory not support yet
 * 
 * @author Daniel Liu
 */
public class DeleteFileCommand extends AbstractScriptCommand {
	private File file = null;

	public DeleteFileCommand() {
	}

	public void excute() throws TinyScriptException {
		Loggers.getLogger().info("executing delete " + this.file);
		FileOperationUtils.deleteFile(file);
	}

	public String getCommand() {
		return "delete";
	}

	public void setArguments(String... arguments) throws TinyScriptException {
		this.checkArgumentsLength(1, arguments);
		this.file = new File(arguments[0]);
		Loggers.getLogger().config("set args: delete " + file + " -> " + file);
	}

	public DeleteFileCommand clone() throws CloneNotSupportedException {
		return (DeleteFileCommand) super.clone();
	}
}
